package com.tencent.wxcloudrun.service.impl;

import com.tencent.wxcloudrun.dao.StatisticsMapper;
import com.tencent.wxcloudrun.dto.RankRequest;
import com.tencent.wxcloudrun.dto.RankResponse;
import com.tencent.wxcloudrun.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StatisticsServiceImpl implements StatisticsService {

    private final StatisticsMapper statisticsMapper;

    @Autowired
    public StatisticsServiceImpl(StatisticsMapper statisticsMapper) {
        this.statisticsMapper = statisticsMapper;
    }

    @Override
    public RankResponse getRankData(RankRequest request) {
        RankResponse response = new RankResponse();
        response.setTotalUsers(statisticsMapper.countTotalUsers());
        response.setCurrentRank(statisticsMapper.getUserRank(request.getWeId()));
        response.setTotalActivities(statisticsMapper.countDailyActivities(request.getRecordDate()));
        return response;
    }
} 